#define  _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
void insert(int arr[], int n, int m)
{
    int i = 0;
    int j = 0;
    if (m <= arr[0])
    {
        int temp = arr[0];
        arr[0] = m;
        for (i = n; i > 1; i--)
        {
            arr[i] = arr[i - 1];
        }
        arr[i] = temp;
        return;
    }
    if (m >= arr[n - 1])
    {
        arr[n] = m;
        return;
    }
    for (i = 0; i < n - 1; i++)
    {
        if (m >= arr[i] && m <= arr[i + 1])
        {
            int temp = arr[i + 1];
            arr[i + 1] = m;
            for (j = n; j > i + 2; j--)
            {
                arr[j] = arr[j - 1];
            }
            arr[j] = temp;
            return;
        }
    }
}
    int main()
    {
        int n = 0;
        int arr[51] = { 0 };
        int m = 0;
        scanf("%d", &n);
        int i = 0;
        for (i = 0; i < n; i++)
        {
            scanf("%d", &arr[i]);
        }
        scanf("%d", &m);
        insert(arr, n, m);
        for (i = 0; i < n + 1; i++)
        {
            printf("%d ", arr[i]);
        }
        return 0;
    }